Formius.Element_Container_Repeat_Row = $.inherit(Formius.Element_Container, {
	_controls: {
		add: null,
		remove: null,
		up: null,
		down: null
	},
	__constructor: function(element, form, settings) {
		this.__base(element, form, settings);
		
		this._controls.add		= this.__createControl(this.settings.selectors.repeat.add);
		this._controls.remove	= this.__createControl(this.settings.selectors.repeat.remove);
		this._controls.up		= this.__createControl(this.settings.selectors.repeat.up);
		this._controls.down		= this.__createControl(this.settings.selectors.repeat.down);
	},
	__createControl: function(selector) {
		var control;
		if ((control = this.getElement().find(selector)) && control.size()) {
			return this.createElement(control.get(0));
		}
		return null;
	},
	_createEmptyRow: function() {
		return this.getParent().getTemplate().clone();
	},
	add: function() {
		if (this.getParent().canAdd()) {
			var newRow = this._createEmptyRow();
			this.getElement().after(newRow);

			this.getParent().add(newRow, this.getParent().indexOf(this) + 1);
		}
	},
	remove: function() {
		if (this.getParent().canRemove()) {
			this.getParent().remove(this);
		}
	},
	up: function() {
		alert('up');
	},
	down: function() {
		alert('down');
	}
});